#include <iostream>
#include <map>
using namespace std;

map<string,int> ma;
int maxNum = 0;

signed main()
{
    string s,word;
    getline(cin,s);
    for(int i=0;i<s.size();i++){
        int j=i;
        while(s[j]>='a'&&s[j]<='z'||s[j]>='A'&&s[j]<='Z'||s[j]>='0'&&s[j]<='9'){
            if(s[j]>='A'&&s[j]<='Z')    s[j]+=32;
            j++;
        }
        if(j>i){
            word = s.substr(i,j-i);
            ma[word]++;
            maxNum = max(maxNum,ma[word]);
            i = j;
        }
    }
    for(auto it:ma){
        if(it.second==maxNum){
            cout<<it.first<<" ";
            break;
        }
    }
    cout<<maxNum;
    return 0;
}
